import sys
import pygame
from vector import *

pygame.init()
screen = pygame.display.set_mode(const.size)
ball_color = const.get_random_ball_color()
ball_pos = const.get_random_ball_pos()
clock = pygame.time.Clock()

# ran_dir = math.pi
ran_dir = get_random_direction()
print('初始方向', ran_dir)

b = Ball(x=0, y=0, radis=50, direction=ran_dir, speed=20)
USER_EVENT = pygame.USEREVENT
pygame.time.set_timer(USER_EVENT, 1000)
while True:
    screen.fill(const.screen_color)
    clock.tick(50)
    # 在screen上画一条线
    pygame.draw.line(screen, ball_color, (0, 0), const.size, 2,)
    # 在screen上画一个圆
    ball_on_screen = pygame.draw.circle(color=ball_color, radius=b.radis, center=(b.x, b.y), surface=screen)
    b.move()
    # 更新所有显示
    pygame.display.update()
    # pygame.display.flip()
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            sys.exit()
        # elif event.type == USER_EVENT:
        #     bb = Ball(direction=get_random_direction(), speed=30, x=0, y=0)
